package com.xteam.xnetworkdisk.utils;

import com.xteam.xnetworkdisk.constant.Constant;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolManager {
    // 创建一个固定大小的线程池，线程池大小为 5
    private static final ExecutorService executorService = Executors.newFixedThreadPool(Constant.THREAD_POOL_NUMBER);

    // 私有化构造函数，防止实例化
    private ThreadPoolManager() {}

    // 提供公共的静态方法来获取线程池
    public static ExecutorService getExecutorService() {
        return executorService;
    }

    // 添加一个关闭线程池的方法（可选）
    public static void shutdown() {
        if (executorService != null && !executorService.isShutdown()) {
            executorService.shutdown();
        }
    }
}
